// grid.h: interface for the Grid class.
//
//////////////////////////////////////////////////////////////////////

#ifndef GRID_H
#define GRID_H

#include <qwidget.h>
#include <qstringlist.h>
#include <qcolor.h>
#include <qpixmap.h>

class Grid : public QObject
{
	Q_OBJECT

public:
	Grid(QObject *parent = 0);

	void draw(QPainter &p);
	bool needsFullRedraw();
	QPixmap	*getPixmap();
	
	/*
	**  Grid configuration
	*/
	void setGridLinesY(int num);
	void setGridLinesX(int num);

	int getGridLinesY();
	int getGridLinesX();

	void setGridArea(QRect &r);
	QRect getGridArea();
	void setLabelArea(QRect &r);
	QRect getLabelArea();

	bool drawLabels();
	void setDrawLabels(bool b);

	/*
	**  Color information functions
	*/
	QColor getLineColor();
	void   setLineColor(QColor color);
	
	QColor getTextColor();
	void   setTextColor(QColor color);

	QColor getBgColor();
	void setBgColor(QColor color);
	/*
	**  Axis setup functions
	*/
	void setAxisLabelY(QString s);
	void setTitle(QString s);
	void setAxisLabelX(QString s);

	QString getAxisLabelY();
	QString getAxisLabelX();
	QString getTitle();

	void setValuesX(QStringList list);
	void setValuesY(QStringList list);

	QStringList getValuesX();
	QStringList getValuesY();

	void redrawNextUpdate();


	void setTitleFont(QFont titleFont);
	QFont getTitleFont();

	void setValuesFont(QFont valuesFont);
	QFont getValuesFont();

	void setAxisLabelsFont(QFont axisLabelFont);
	QFont getAxisLabelsFont();

private:
	QPixmap pixmap;

	void	calculateLabelAreas();
	bool	axisLabels;

	QRect gridArea;
	QRect labelArea;
	QRect axisAreaX;
	QRect axisAreaY;
	QRect titleArea;

	QColor	lineColor;
	QColor	textColor;
	QColor  bgColor;
	int		numGridLinesX;
	int		numGridLinesY;	

	QString axisLabelY;
	QString axisLabelX;
	QString	title;
	
	QStringList valuesX;
	QStringList valuesY;
	bool		showValuesX;
	bool		showValuesY;
	bool		needsUpdate;

	QFont mAxisLabelsFont;
	QFont mTitleFont;
	QFont mValuesFont;

	/***DEBUG****/
	bool colorToggle;
};

#endif
